﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;

namespace HWR_Ants
{
    public static class Tools
    {
        public static string NL = System.Environment.NewLine;

        public static string[] ToSeperatedString(this string s, string sep)
        {
            string[] array = new string[] { sep };
            return s.Split(array, StringSplitOptions.None);
        }

        public static void writeXML<T>(T objectToSerialize, string fileName)
        {
            XmlSerializer ser = new XmlSerializer(typeof(T));
            FileStream fs = new FileStream(fileName, FileMode.Create);
            ser.Serialize(fs, objectToSerialize);
            fs.Close();
        }

        public static T readXML<T>(string fileName)
        {
            T ret;
            XmlSerializer ser = new XmlSerializer(typeof(T));
            StreamReader sr = new StreamReader(fileName);
            ret = (T)ser.Deserialize(sr);
            sr.Close();
            return ret;
        }
    }
}
